memory: properly check guest memory ranges in XENMEM_exchange handling
authorJan Beulich <jbeulich@suse.com>
Tue, 4 Apr 2017 12:47:46 +0000 (14:47 +0200)
committerJan Beulich <jbeulich@suse.com>
Tue, 4 Apr 2017 12:47:46 +0000 (14:47 +0200)
commit938fd2586eb081bcbd694f4c1f09ae6a263b0d90
tree1a759254e8a771e813750b6149397e517915d950
parentcde048340afa125514f77368f62fbea9805a68f9
memory: properly check guest memory ranges in XENMEM_exchange handling

The use of guest_handle_okay() here (as introduced by the XSA-29 fix)
is insufficient here, guest_handle_subrange_okay() needs to be used
instead.

Note that the uses are okay in
- XENMEM_add_to_physmap_batch handling due to the size field being only
  16 bits wide,
- livepatch_list() due to the limit of 1024 enforced on the
  number-of-entries input (leaving aside the fact that this can be
  called by a privileged domain only anyway),
- compat mode handling due to counts there being limited to 32 bits,
- everywhere else due to guest arrays being accessed sequentially from
  index zero.

This is CVE-2017-7228 / XSA-212.

Reported-by: Jann Horn <jannh@google.com>
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
xen/common/memory.c
xen/include/asm-x86/x86_64/uaccess.h